package com.wind.cqboot.plugin;

import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;

import net.lz1998.pbbot.bot.Bot;
import net.lz1998.pbbot.bot.BotPlugin;
import onebot.OnebotEvent;

@Component
public class AdPlugin extends BotPlugin
{
    @Override
    public int onGroupMessage(@NotNull Bot bot,
            @NotNull OnebotEvent.GroupMessageEvent event)
    {
        String msg = event.getRawMessage();
        Long groupId = event.getGroupId();
        Long userId = event.getUserId();
        if (msg.contains("阿里云") && msg.contains("https://www.aliyun.com/"))
        {
            String content = " 被检测到广告,已被永久踢出群聊,如果误踢，请管理员加回";
            String result = userId + content;
            bot.sendGroupMsg(groupId, result, false);
            bot.setGroupKick(groupId, userId, true);
            return MESSAGE_BLOCK;
        }
        // 继续执行下一个插件
        return MESSAGE_IGNORE;
    }
}
